package com.cwh.springbootMybatis;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;

@SpringBootApplication
/*public class Application implements CommandLineRunner{

	*//*@Autowired
    DataSource dataSource;*//*
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
	
	*//**
	 * 查看用了什么数据库连接池
	 *//*
	@Override
	public void run(String... args) throws Exception {
//        System.out.println("DATASOURCE = " + dataSource);
    }
}*/
public class Application extends SpringBootServletInitializer {

	@Autowired
	DataSource dataSource;
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	/**
	 * 查看用了什么数据库连接池
	 */
	public void run(String... args) throws Exception {
		System.out.println("DATASOURCE = " + dataSource);
	}

	/*将springboot项目打包成war*/
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		// 注意这里要指向原先用main方法执行的Application启动类
		return builder.sources(Application.class);
	}
}
